"""
最底层io
PLC中io的布局

io的读写功能
io1 [True/False]
io2 [True/False]
io3 [True/False]

io的诊断功能
io_diagnosis_config:[
    {
        "use_diagnosis":False,
        "diagnosis_value": False
    }
]

io_detail_info:[
    {
        "enable": True
        "reverse": False

        "io_phys: True
    },
]

写

value = input_value

if not enable:
    value = 0

if use_diagnosis:
    value = diagnosis_value

if reverse:
    value = not value

set_phy_io(io_name, value)

读

phy_value
if reverse:
    phy_value = not pyh_value

if not enable:
    phy_value = 0

if use_diagnosis:
    phy_value = diagnosis_value

modify_logic_io_value(phy_value)

"Blowning": {
            "name": "/runtime1/signal/channel_info",
            "io_diagnose": {
                "name":"吹气",
                "diagnose": "Blowning_diagnose",
            }
        },
"Blowning_diagnose":{
    "name": "/runtime1/param/Blowning_diagnose",
}
"Blowning_in": {
            "name": "/runtime1/signal/channel_info",
        },

"io_diagnosis_detail_info":{
            "name": "/runtime2/io_detail_info"
        }
"""


def _read_process_data(param_name):
    """读参数"""
    return [{}, {}, {}]


def _write_process_data(param_name, value):
    """写参数"""
    pass


READ_PROCESS_DATA = _read_process_data
WRITE_PROCESS_DATA = _write_process_data


DIAGNOSIS_STATE = 3  # 是否开始诊断
DIAGNOSIS_VALUE = 4  # 诊断值

IO_DIAGNOSIS_INFOS = []


def io_diagnose_init(diagnose_param_name):
    """对io诊断模块进行初始化"""
    WRITE_PROCESS_DATA(diagnose_param_name, {
        "use_diagnose": False,
        "diagnose_value": False})


def set_io_diagnose(diagnose_param_name, diagnose_enable, diagnose_value):
    """启用io诊断功能"""
    value = {
        "use_diagnose": diagnose_enable,
        "diagnose_value": diagnose_value
    }

    WRITE_PROCESS_DATA(diagnose_param_name, value)


def io_diagnose_info(diagnose_param_name):
    """io诊断的具体信息"""
    return READ_PROCESS_DATA(diagnose_param_name)
